package com.NyCloud.controller;


import cn.dev33.satoken.secure.SaSecureUtil;
import cn.dev33.satoken.util.SaResult;
import com.NyCloud.entity.User;
import com.NyCloud.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 作者
 * @since 2024-06-11
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户")
@CrossOrigin
public class UserController {

    @Autowired
    private IUserService userService;

    @PostMapping("/updateInfo")
    @ApiOperation("更新用户信息")
    public SaResult updateInfo(@RequestBody User user) {
        userService.updateById(user);
        return SaResult.ok();
    }

    @GetMapping("/{userId}")
    @ApiOperation("获取用户信息")
    public SaResult getUserInfo(@PathVariable String userId) {
        User user = userService.getById(Integer.parseInt(userId));
        user.setPassword("");
        return SaResult.data(user);
    }

}
